<?php
/**
 * Prado Portal.
 *
 * @author Steen Rabol <steen.rabol@gmail.com>
 * @link http://www.pradoportal.dk/
 * @copyright Copyright &copy; 2006,2007,2008 Steen Rabol
 * @license http://www.pradoportal.dk
 * @version $Id: PortalUserRecord.php 289 2008-11-14 05:34:40Z steen.rabol@gmail.com $
 */

Prado::using('Application.Common.Data.PortalActiveRecord');
Prado::using('Application.Common.Data.PortalRoleRecord');
Prado::using('Application.Common.Data.PortalLanguageRecord');

class PortalUserRecord extends PortalActiveRecord
{
	const TABLE='tblusers';

	public $id;
	public $name;
	public $full_name;
	public $role;
	public $password;
	public $vcode;
	public $email;
	public $reg_time;
	public $status;
	public $sitenews;
	public $culture;

	private $_roletxt		= null;
	private $_culturetxt	= null;

	public static function finder($className=__CLASS__)
	{
		return parent::finder($className);
	}

	public function getRole2Text()
	{
		if($this->_roletxt === null)
		{
			$r	= PortalRoleRecord::finder()->findByid($this->role);
			if($r)
				$this->_roletxt	= $r->name;
		}

		return $this->_roletxt;
	}

	public function getCulture2Txt()
	{
		if($this->_culturetxt === null)
		{
			$c = PortalLanguageRecord::finder()->findByculture($this->culture);
			if($c)
				$this->_culturetxt	= $c->name;
		}

		return $this->_culturetxt;
	}

	public function getSiteNewsAsText()
	{
		if($this->sitenews == 0)
			return Prado::localize('No');

		if($this->sitenews == 1)
			return Prado::localize('Yes');

	}
}
?>